package com.leyou.item.client;

import com.leyou.common.pojo.PageResult;
import com.leyou.item.dto.SpecGroupDTO;
import com.leyou.item.dto.SpuDTO;
import com.leyou.item.entity.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {
    /**
     * 查询所有spu的接口，分页查询也可以
     */
    /**
     * 分页查询Spu
     */
    @GetMapping("/spu/page")
    public PageResult<SpuDTO> spuPageQuery(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                           @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                           @RequestParam(value = "key", required = false) String key,
                                           @RequestParam(value = "saleable", required = false) Boolean saleable);

    /**
     * 根据当前spuId查询出旗下所有sku的集合
     */
    @GetMapping("/sku/of/spu")
    public List<Sku> findSkusBySpuId(@RequestParam("id") Long id);

    /**
     * 根据分类id查询所有可用于过滤的规格参数
     */
    @GetMapping("/spec/params")
    public List<SpecParam> findSpecParams(@RequestParam(value = "gid", required = false) Long gid,
                                          @RequestParam(value = "cid", required = false) Long cid,
                                          @RequestParam(value = "searching", required = false) Boolean searching);

    /**
     * 根据spuId查询SpuDetail对象
     */
    @GetMapping("/spu/detail")
    public SpuDetail findSpuDetailById(@RequestParam("id") Long id);

    /**
     * 根据分类id集合获取分类集合
     */
    @GetMapping("/category/list")
    public List<Category> findCategoryByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据品牌id的集合查询品牌对象的集合
     */
    @GetMapping("/brand/list/of/ids")
    public List<Brand> findBrandsByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据spuId查询SpuDTO对象 【在SpuDTO对象中要给spuDetail和skus属性赋值】
     */
    @GetMapping("/spu/{id}")
    public SpuDTO findSpuDTOBySpuId(@PathVariable("id") Long id);

    /**
     * 根据品牌id查询品牌对象的接口
     */
    @GetMapping("/brand/{id}")
    public Brand getBrandById(@PathVariable("id") Long id);

    /**
     * 根据第三级分类id查询规格组集合，每个规格组对象中要包含规格参数集合
     */
    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO> findSpecGroupDTOByCid(@RequestParam("id") Long id);

    /**
     * 根据skuid的集合批量查询sku对象集合
     */
    @GetMapping("/sku/list")
    public List<Sku> findSkusByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 减库存
     */
    @PutMapping("/stock/minus")
    public Void minusStock(@RequestBody Map<Long, Integer> paramMap);

}
